package com.baizhi.controller;

import com.baizhi.entity.Ems;
import com.baizhi.service.EmsService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

//@Controller
@RestController
@CrossOrigin  //解决跨域问题
public class EmsController {

    @Resource
    private EmsService emsService;
    private Ems ems;

    @RequestMapping("/findAllEms")
    public List<Ems> findAllEms(){
        return emsService.FindAllEms();
    }

    @RequestMapping("/addEms")
    public String addEms(@RequestBody Ems ems){
        System.out.println(ems);
        emsService.addEms(ems);
        return "OK";
    }

    @RequestMapping("/deleteEms")
    public void deleteEms(Integer id){
        emsService.deleteEms(id);
    }

    @RequestMapping("/updateEms")
    public void updateEms(@RequestBody Ems ems){
        System.out.println(ems+"11111111");
        emsService.updateEms(ems);
        //return "ok";
    }

    @RequestMapping("/queryEmsById")
    public Ems queryEmsById(Integer id){
       Ems ems= emsService.queryByIdEms(id);
        System.out.println(ems);
      return  ems;
    }

}
